/* eslint-disable no-mixed-spaces-and-tabs */
/* eslint-disable indent */
import React, { Component } from "react";
import { BrowserRouter as Router, Route, Switch, Redirect, Link } from "react-router-dom";
import { Layout, Menu, Dropdown, Icon, message, Form, Button, Modal, Input, Alert } from "antd";
import Login from "./login.jsx";


import EduBigScreen from "./edubigscreen.jsx"
//test
import TestScreen from "./testScreen.jsx"

import { OutGrid, InnerGrid, Patrol, Polling, BigScreenSetUp, BigScreenHoc, KaoQin } from "./bigscreen.jsx";
import Permission from "./test.jsx";
import EducationPage from './education.jsx'
import { AttendanceUserBind } from './attendanceuserbind.jsx';
import { listMenuByPermission, getUserPermissionApi, getSchoolIdScreenUrlApi, updateUserApi, getLogOutApi} from "../js/api.js";
import { iconFontUrl, } from "../js/config.js";
import { EduDepartmentUserManager, EduDepartmentSchoolManager, EduDepartmentEduManager, EduSchoolblueteeth, FeaturesitemOfAdmin, Featuresset, SystemUsedStatics } from "./eduadmin.jsx";
// import FeaturesitemAdmin from "./eduadmin.jsx";
import { EduDepartmentInspect } from "./edussv.jsx";

import { patrolwordRouter, inspectwordRouter, dutyweekwordRouter } from './staticstowordrouter.jsx'

import { WeekRecipesComponent } from './recipes.jsx'

import {
    SchoolUserManager, BlueteethDeviceManager, SchoolAddressManager, AddressWithBlueteethManager,
    SchoolManualManager, SchoolMessagepushManager, SchoolInspectpushManager, SchoolSafetyscenePushManager,
    SchoolEventPushManager, SchoolKaoQinPushManager, SchoolZhiZhouPushManager, SchoolBlueTeethManager, SchoolEmergencyManager,
    SignBlueteeth, AttendanceSchedule, AttendanceRecord, AttendanceInquiry, Attendancesetup
} from "./schooladmin.jsx";

import { Dutyweeksetup, SchoolDutyWeekConditionManager, DutyweekClassToBluteeth, Publiczhizhouitemdeploy, DutyWeekCharts, Dutyweekpointsetup, DutyWeekDisplay } from './dutyweek.jsx'
import { StudentsGrid, FourSepcialGrid, AddGridFiveOldStaffGrid } from './studentsgrid.jsx'
import {
    SchoolTeamAssignmentManager, PatrolRouteManager, SchoolPatrolPlanManager, SchoolPatrolConditionManager,
    SchoolInspectWithCheckpointManager, SchoolInspectPlanManager, SchoolInspectConditionManager, SchoolSafetySceneManager,
    PatrolCharts, InspectCharts, MonitorTable, Electricalsafety, ElectricalsafetyDeploy,
    SmokeDevice, UpAndDownDevice, FaceImageManage, Visitorrecord, VisitorrecordData, Score
} from "./schoolsafetysupervisor.jsx";
import { Attendance, OriginalList } from "./schoolattendance.jsx"

import { ImportGridOneData, TreeDemo } from "./inadmingrid.jsx"

import { OutAdminGrid } from "./studentsgrid.jsx"

import { UpdatePassword } from "./judgepassword.jsx"
import { NFCinspectRecord } from "./nfcinspectrecord.jsx"
import { EduInspectNum, EduInspectFinishedRate, EduInspectCompositeRank } from "./edudailystatistics.jsx"
import {
    PatrolNumRank, PatrolRatesRank, PatrolPointsRank, InspectNumRank, DangerNumRank, DangerCategory, DangerDealRate,
    InspectClassComplete, InspectPoints, InspectClassPoints
} from "./dailystatistics.jsx"
import {
    EduPatrolNumRank, EduPatrolRatesRank, EduPatrolPointsRank,
    EduDangerNumRank, EduDangerCategory, EduDangerDealRateRank, ComprehensivePointsRank, xunchaPlan, XunchaRecord, DailyRecord
} from "./edudailystatistics.jsx"

import { DutyWeekCategorySet } from "./dutyweek.jsx"
import { DutyWeekContent } from "./dutyweek.jsx"
import { DutyWeekPlace } from "./dutyweek.jsx"
import { MunicipalityPage } from './bigscreen/municipalityPage/municipalityPage.jsx'
import { CountyPage } from './bigscreen/countyPage/countyPage.jsx'

import { getScreenSecretApi } from "../js/api.js"
import { QueryRecord } from "./queryrecord.jsx";
import { InspectPlanRecover, PushRecover, TermInspectPlanRecover } from "./dataRecover.jsx";
import { CountyStatistic } from "./countystatistic.jsx"
import { SchoolStatistic } from "./schoolstatistic.jsx";
import { ScoreRank } from "./scorerank.jsx"
import { PlanMake } from "./inspectplan.jsx"
import { PushRecord } from "./pushrecord.jsx";
import { EpidemicContent, EpidemicForm } from "./epidemic.jsx";
import { QuestionForm } from "./questionForm.jsx";
import { SchoolInfoEditor } from "./schoolInfoEditor.jsx";
import { ImageSharpening } from "./imagedeal.jsx";

const { Content, Sider, Header } = Layout;
const SubMenu = Menu.SubMenu;

const IconFont = Icon.createFromIconfontCN({
    scriptUrl: iconFontUrl,

});
const info = () => {


    message.info('无查看权限', 0.2);
};



const pages = [
    {
        path: "/userManager/eduusermannage", //教育局用户管理
        component: EduDepartmentUserManager,
    },
    {
        path: "/userManager/featuresset", //教育局用户管理
        component: Featuresset,
    },
    {
        path:"/xunchaWork/xunchaPlan", //教育局巡查计划
        component:xunchaPlan,
    },
    {
        path:"/xunchaWork/xunchaRecord", //教育局专项巡查记录查询
        component:XunchaRecord,
    },
    {
        path:"/xunchaWork/dailyRecord", //教育局日常巡查记录查询
        component:DailyRecord,
    },
    {
        path: "/userManager/systemusedstatics", //系统使用情况    
        component: SystemUsedStatics,
    },

    {
        path: "/functionManager/featuresitemOfAdmin", //功能模块   
        component: FeaturesitemOfAdmin,
    },
    {
        path: "/powerManager/featuresset", //权限配置  
        component: Featuresset,
    },
    
    {
        path: "/userManager/childdepartmentmanage", //子单位管理
        component: EduDepartmentSchoolManager,
    }, {
        path: "/userManager/edumanager", //教育局管理
        component: EduDepartmentEduManager,
    }, {
        path: "/userManager/teamassignment", //人员班组分配
        component: SchoolTeamAssignmentManager,
    }, {
        path: "/userManager/usermanage", //子单位用户管理
        component: SchoolUserManager,
    },
    {
        path: "/userManager/emergency", //紧急联系人配置
        component: SchoolEmergencyManager,
    },
    {
        path: "/attendance/attendance", //签到管理
        component: Attendance,
    }, {
        path: "/attendance/originallist", //签到人员分组
        component: OriginalList,
    }, {
        path: "/inspect/inspectitemmanage", //巡检项配置
        component: SchoolManualManager,
    }, {
        path: "/inspect/eduinspectcondition", //教育局抽检情况
        component: EduDepartmentInspect,
    }, {
        path: "/inspect/inspectcharts", //云巡检大数据
        component: InspectCharts,
    }, {
        path: "/inspect/inspectwithcheckpoint", //巡检排查点规划
        component: SchoolInspectWithCheckpointManager,
    }, {
        path: "/inspect/inspectplan", //巡检计划制定
        component: SchoolInspectPlanManager,
    }, {
        path: "/inspect/inspectcondition", //巡检情况统计
        component: SchoolInspectConditionManager,
    }, {
        path: "/inspect/inspectword", //巡检报表
        component: inspectwordRouter,
    }, {
        path: "/inspect/nfcrecord", //NFC巡检记录
        component: NFCinspectRecord,
    }, {
        path: "/patrol/patrolcharts", //云巡更大数据
        component: PatrolCharts,
    }, {
        path: "/patrol/patrolroute", //巡更路线规划
        component: PatrolRouteManager,
    }, {
        path: "/patrol/patrolplan", //巡更计划制定
        component: SchoolPatrolPlanManager,
    }, {
        path: "/patrol/patrocondition", //巡更情况统计
        component: SchoolPatrolConditionManager,
    }, {
        path: "/patrol/patrolword", //巡更报表
        component: patrolwordRouter,
    }, {
        path: "/messagepush/dailypatrolpush", //巡更推送配置
        component: SchoolMessagepushManager,
    }, {
        path: "/messagepush/inspectpush", //巡检推送配置
        component: SchoolInspectpushManager,
    }, {
        path: "/messagepush/safetyscenepush", //隐患上报配置
        component: SchoolSafetyscenePushManager,
    },
    {
        path: "/messagepush/eventpush", //事件推送配置
        component: SchoolEventPushManager,
    },
    {
        path: "/messagepush/kaoqinrecordpush", //考勤推送配置
        component: SchoolKaoQinPushManager,
    },
    {
        path: "/messagepush/zhizhourecordpush", //值周推送配置
        component: SchoolZhiZhouPushManager,
    },
    {
        path: "/electricalsafetyweb/monitor", //用电安全监测
        component: MonitorTable,
    }, {
        path: "/electricalsafetyweb/electricityInquiry", //用电安全查询
        component: Electricalsafety,
    }, {
        path: "/electricalsafetyweb/electricalsafetyDeploy", //用电设备配置
        component: ElectricalsafetyDeploy,
    }, {
        path: "/safetyscene/safetyscene", //安全隐患排查
        component: SchoolSafetySceneManager,
    }, {
        path: "/deviceManager/blueteethdevice", //巡检更设备管理
        component: BlueteethDeviceManager,
    }, {
        path: "/deviceManager/address", //检查点管理
        component: SchoolAddressManager,
    }, {
        path: "/deviceManager/blueteethwithaddress", //设备检查点关联
        component: AddressWithBlueteethManager,
    }, {
        path: "/deviceManager/blueteethmanage", //硬件设备配置
        component: SchoolBlueTeethManager,
    }, {
        path: "/deviceManager/signblueteeth", //签到设备配置
        component: SignBlueteeth,
    }, {
        path: "/deviceManager/eduinspectmodel", //教育局抽检蓝牙
        component: EduSchoolblueteeth,
    },
    {
        path: "/deviceManager/bigscreensetup", //数据大屏配置
        component: BigScreenSetUp,
    },
    {
        path: "/fireEquipment/smokeDevice", //烟感
        component: SmokeDevice,
    }, {
        path: "/accessDevice/upAndDownDevice", //防撞柱
        component: UpAndDownDevice,
    }, {
        path: "/kaoqin/faceImageManage", //人脸识别闸机
        component: FaceImageManage,
    }, {
        path: "/kaoqin/attendanceschedule", //考勤日历
        component: AttendanceSchedule,
    }, {
        path: "/kaoqin/attendancerecord", //考勤记录
        component: AttendanceRecord,
    },
    {
        path: "/kaoqin/attendanceuserbind",  //人脸机人员绑定
        component: AttendanceUserBind,
    },
    {
        path: "/kaoqin/AttendanceInquiry", //考勤记录
        component: AttendanceInquiry,
    }, {
        path: "/kaoqin/attendancesetup", //考勤配置
        component: Attendancesetup,
    }, {
        path: "/inspect/dutyweek", //考勤配置
        component: Dutyweeksetup,
    }, {
        path: "/visitorManage/visitorrecord", //访客记录
        component: Visitorrecord,
    }, {
        path: "/visitorManage/visitorrecordData", //访客数据统计
        component: VisitorrecordData,
    }, {
        path: "/userManager/score", //用户积分考核
        component: Score,
    },
    // , {
    //     path: "/dutyweek/dutybluetooth", //值周地点任务配置
    //     component: DutyBlueteeth,
    // },
    {
        path: "/dutyweek/dutyweekCharts", //值周数据
        component: DutyWeekCharts,
    },
    {
        path: "/dutyweek/dutyweekword", //值周报表
        component: dutyweekwordRouter,
    },

    {
        path: "/dutyweek/dutyweeksetup", //值周任务配置
        component: Dutyweeksetup,
    },
    {
        path: "/dutyweek/dutyweekpointsetup", //值周打卡点配置
        component: Dutyweekpointsetup,
    },

    {
        path: "/dutyweek/dutyweekcategory", //值周时间段配置
        component: DutyWeekCategorySet,
    },
    {
        path: "/dutyweek/dutyweekcontents", //值周内容配置
        component: DutyWeekContent,
    },
    {
        path: "/dutyweek/dutyweekplace", //值周地点配置
        component: DutyWeekPlace,
    },

    {
        path: "/dutyweek/dutyweekquery", //值周查询
        component: SchoolDutyWeekConditionManager,
    },
    {
        path: "/dutyweek/dutyweekclasstoblueteeth", //值周地点设备关联
        component: DutyweekClassToBluteeth,

    },
    {
        path: "/dutyweek/dutyweekdisplay", //值周地点设备关联
        component: DutyWeekDisplay,

    },
    {
        path: "/dutyweek/publiczhizhouitemdeploy", //值周数据导入
        component: Publiczhizhouitemdeploy,

    },

    {
        path: "/outofschoolgrid/studentsgrid", //生源网格
        component: StudentsGrid,
    },
    {
        path: "/outofschoolgrid/fourspecialgrid", //四特网格
        component: FourSepcialGrid,
    },

    {
        path: "/outofschoolgrid/fiveoldgrid", //五老网格
        component: AddGridFiveOldStaffGrid,
    },
    {
        path: "/recipes/weekrecipes", //每周食谱
        component: WeekRecipesComponent,
    },
    // {
    //     path: "/staticstoword/patrolstatics", //巡更统计
    //     component: staticstowordRouter,
    // },
    {
        path: "/basicdataimport/gridone",
        component: ImportGridOneData,
    },

    {
        path: "/outofschoolgrid/outadmingrid", //五老网格
        component: OutAdminGrid,
    },
    {
        path: "/inadmingrid/inschoolgrid",
        component: ImportGridOneData,
        //component: TreeDemo,
    },
    {
        path: "/patrol/patrolnumrank",  //巡更统计分析--个人巡更次数排名
        component: PatrolNumRank,
    },
    {
        path: "/patrol/patrolratesrank",  //巡更统计分析--个人巡更完成率排名
        component: PatrolRatesRank,
    },
    {
        path: "/patrol/patrolpointsrank",  //巡更统计分析--个人巡更积分排名
        component: PatrolPointsRank,
    },
    {
        path: "/safetyscene/dangernumrank",  //隐患统计分析--个人隐患上报次数排名
        component: DangerNumRank,
    },
    {
        path: "/safetyscene/dangercategory",  //隐患统计分析--个人隐患上报次数排名
        component: DangerCategory,
    },
    {
        path: "/safetyscene/dangerdealrate",  //隐患统计分析--个人隐患上报次数排名
        component: DangerDealRate,
    },
    {
        path: "/inspect/rankinspectiontimes",
        component: InspectNumRank,
    },
    {
        path: "/inspect/inspectioncompletionrateranking",
        component: InspectClassComplete,
    },
    {
        path: "/inspect/comprehensiveinspectionranking",
        component: InspectPoints,
    },
    {
        path: "/inspect/inspectclasspointsranking",
        component: InspectClassPoints,
    },
    {
        path: "/inspectionstatisticalanalysis/eduinspectnum",
        component: EduInspectNum,
    },
    {
        path: "/inspectionstatisticalanalysis/eduinspectfinishedrate",
        component: EduInspectFinishedRate,
    },
    {
        path: "/inspectionstatisticalanalysis/eduinspectcomposite",
        component: EduInspectCompositeRank,
    },
    {
        path: "/dayilypatrolstatistics/edupatrolnum",   //教育局巡更统计分析--学校巡更次数排名
        component: EduPatrolNumRank,
    },
    {
        path: "/dayilypatrolstatistics/edupatrolfinishedrate",   //教育局巡更统计分析--学校巡更完成率排名
        component: EduPatrolRatesRank,
    },
    {
        path: "/dayilypatrolstatistics/edupatrolcomposite",   //教育局巡更统计分析--学校巡更积分排名
        component: EduPatrolPointsRank,
    },
    {
        path: "/dangerdayilystatistics/edudangernum",   //教育局巡更统计分析--学校隐患次数排名
        component: EduDangerNumRank,
    },
    {
        path: "/dangerdayilystatistics/edudangercategory",   //教育局巡更统计分析--学校隐患类型分布
        component: EduDangerCategory,
    },
    {
        path: "/dangerdayilystatistics/edudangerdealrate",   //教育局巡更统计分析--学校隐患结案率
        component: EduDangerDealRateRank,
    },
    {
        path: "/comprehensivestatisticalanalysis/comprehensivepoints",   //教育局综合排名--学校综合积分
        component: ComprehensivePointsRank,
    },
    {
        path: "/dutyweek/dutyweekcategory", //值周时间段配置
        component: DutyWeekCategorySet,
    },
    {
        path: "/pushrecord/queryrecord", //值周时间段配置
        component: QueryRecord,
    },
    {
        path: "/dataRevocer/inspectPlanRecover", //巡检计划恢复
        component: InspectPlanRecover,
    },
    {
        path: "/dataRevocer/pushRecover", //巡更巡检推送恢复
        component: PushRecover,
    },
    {
        path: "/dataRevocer/termInspectPlanRecover", //恢复上学期巡检计划
        component: TermInspectPlanRecover,
    },
    {
        path: "/countyStatistic/countyStatisticRank", //区县数据统计
        component: CountyStatistic,
    },
    {
        path: "/homePage/scoreRank", //首页积分排名
        component: ScoreRank,
    },
    {
        path: "/inspectPlan/planMake", //巡检计划制定
        component: PlanMake,
    },
    {
        path: "/messagepush/pushrecord", //巡检计划制定
        component: PushRecord,
    },
    {
       
        path: "/schoolStatistic/schoolStatisticRank",  //学校数据统计
        component: SchoolStatistic,
    }, 
    {
        path: "/epidemicManage/epidemicContent",  //防疫每日打卡内容配置
        component: EpidemicForm,
    },
    {
        path: "/epidemicManage/questionForm",  //动态表单
        component: QuestionForm,
    },
    {
        path: "/schoolInfo/infoEditor",  //学校信息编辑
        component: SchoolInfoEditor,
    },
    {
        path: "/imageDeal/sharpening",  //图像处理
        component: ImageSharpening,
    },
    
];

class App extends Component {
    constructor(props) {
        super(props);
    }
    



    render() {
        return (
            <Router>
                <Switch>
                    <Route exact path="/" component={Login} />
                    {/* <Route  path="/bigscreen/:schoolId/:schoolName/:mapType/:module" render={(props) => (
                        
                        
                        <BigScreen{...props} />)} /> */}
                    {/* <Route path="/bigscreen/polling/:schoolId/:schoolName/:mapType/:module/:origin" render={(props) => {

                        let PagePolling = BigScreenHoc(Polling)
                        return <PagePolling {...props} />
                    }} /> */}
                    <Route path="/bigscreen/polling/:schoolId/:mapType" render={(props) => {

                    let PagePolling = BigScreenHoc(Polling)
                    return <PagePolling {...props} />
                    }} />
                    {/* <Route path="/bigscreen/patrol/:schoolId/:schoolName/:mapType/:module/:origin" render={(props) => {

                        let PagePatrol = BigScreenHoc(Patrol)
                        return <PagePatrol {...props} />
                    }} /> */}
                    <Route path="/bigscreen/patrol/:schoolId/:mapType" render={(props) => {

                    let PagePatrol = BigScreenHoc(Patrol)
                    return <PagePatrol {...props} />
                    }} />

                    {/* <Route path="/bigscreen/innergrid/:schoolId/:schoolName/:mapType/:module/:origin" render={(props) => {

                        let PageInnerGrid = BigScreenHoc(InnerGrid)
                        return <PageInnerGrid {...props} />
                    }} /> */}
                    <Route path="/bigscreen/innergrid/:schoolId/:mapType" render={(props) => {

                    let PageInnerGrid = BigScreenHoc(InnerGrid)
                    return <PageInnerGrid {...props} />
                    }} />
                    {/* <Route path="/bigscreen/outgrid/:schoolId/:schoolName/:mapType/:module/:origin" render={(props) => {

                        let PageOutGrid = BigScreenHoc(OutGrid)
                        return <PageOutGrid {...props} />
                    }} /> */}
                    <Route path="/bigscreen/outgrid/:schoolId/:mapType" render={(props) => {

                    let PageOutGrid = BigScreenHoc(OutGrid)
                    return <PageOutGrid {...props} />
                    }} />

                    {/* <Route path="/bigscreen/kaoqin/:schoolId/:schoolName/:mapType/:module/:origin" render={(props) => {

                        let PageKaoQin = BigScreenHoc(KaoQin)
                        return <PageKaoQin {...props} />
                    }} /> */}
                    <Route path="/bigscreen/kaoqin/:schoolId/:mapType" render={(props) => {

                    let PageKaoQin = BigScreenHoc(KaoQin)
                    return <PageKaoQin {...props} />
                    }} />
                    {/* <Route path="/bigscreen/polling/:schoolId/:schoolName/:mapType/:module" render={(props) => (<PagePolling{...props} />)} />
                          <Route path="/bigscreen/innergrid/:schoolId/:schoolName/:mapType/:module" render={(props) => (<PageInnerGrid{...props} />)} />
                          <Route path="/bigscreen/outgrid/:schoolId/:schoolName/:mapType/:module" render={(props) => (<PageOutGrid{...props} />)} /> */}

                    {/* <Route exact path="/edubigscreen/:schoolId/:schoolName/:mapType" render={(props) => (<EduBigScreen{...props} />)} /> */}

                    <Route exact path="/edubigscreen/:secret" render={(props) => (<MunicipalityPage{...props} />)} />

                    <Route path="/edubigscreen/county/:county/:secret" render={(props) => (<CountyPage{...props} />)} />

                    <Route path="/system" component={Permission} />

                    <Route path="/education" component={EducationPage} />

                    <Route exact path="/updatePwd" component={UpdatePassword} />

                    <Route path="*" render={(props) => (<MyRouter {...props} />)} />


                </Switch>
            </Router>
        );
    }
}


class MyRouter extends Component {
    constructor(props) {
        super(props);
        let url = document.location.href;
        let urlSplit = url.split("/");
        let defaultSelectedKeys = urlSplit[4];
        let defaultOpenKeys = urlSplit[3];
        this.state = {
            menuData: [],
            isWatch: 0,
            collapsed: false,
            loading: false,
            // screenurl: 'http: //tidukeji.cn/bigScreenTest/',
            screenurl: 'http: //localhost:bigScreenTest/',
            defaultSelectedKeys: [defaultSelectedKeys],
            defaultOpenKeys: [defaultOpenKeys],
            departmentType: sessionStorage.getItem("departmentType"),
            updatePwdVisible: false,
            confirmLoading: false,
            msg: "",
            alertVisible: false,
            flag: 0,
            buttonLoading: false
        };
    }


    logOff = () => {
        sessionStorage.setItem("username", null);
        sessionStorage.setItem("userId", null);
        sessionStorage.setItem("identityId", null);
        sessionStorage.setItem("departmentId", null);
        sessionStorage.setItem("departmentName", null);
        sessionStorage.setItem("route", null);
        sessionStorage.setItem("departmentType", null);
        sessionStorage.setItem("arr", null);
        sessionStorage.setItem("schoolLevel", null);

        getLogOutApi().then(res => {
            console.log("退出登录==========================")
            document.cookie = "";
        })
        this.props.history.push("/");
    }
    //密码强弱判断
    judgePassword(password) {
        var reg = /^[0-9]{6,16}$|^[a-zA-Z]{6,16}$/   //全是数字或全是字母     6-16个字符   弱
        var reg2 = /^[A-Za-z0-9]{6,16}$/ //数字、26个英文字母      6-16个字符   中
        var reg3 = /^(?![\d]+$)(?![a-zA-Z]+$)(?![~`!@#%^&*()\\_+\-={}|'";:,./<>?]+$)[\da-zA-Z~`!@#%^&*()\\_+\-={}|'";:,./<>?]{6,16}$/ // 由数字、26个英文字母或者下划线组成的字符串    6-16个字符  强
        if (password.match(reg)) {
            console.log("----------弱")
            return 1
        } else if (password.match(reg2)) {
            console.log("----------中")
            return 0
        } else if (password.match(reg3)) {
            console.log("----------高")
            return 0
        } else {
            return 2
        }
    }

    componentDidMount() {
        console.log("-------------------myRoute")
        this.refreshData();
        //校验密码强弱程度
        // var flag = this.judgePassword(sessionStorage.getItem("password"))
        // console.log("flagPwd2", flag)
        let url = document.location.href;
        let urlSplit = url.split("/");
        let defaultSelectedKeys = urlSplit[4];
        let defaultOpenKeys = urlSplit[3];
        this.setState({
            defaultSelectedKeys: [defaultSelectedKeys],
            defaultOpenKeys: [defaultOpenKeys],
            // flag:flag
        });

        // if(document.cookie == ""){
        //     console.log("跳转到首页=================")
        //     let url = "https://tidukeji.cn"
        //     window.location.href= url
        // }

    }



    refreshData() {
        let userId = sessionStorage.getItem("userId");
        let departmentId = sessionStorage.getItem("departmentId");
        let identityId = sessionStorage.getItem("identityId");

        getSchoolIdScreenUrlApi(departmentId, identityId)
            .then(res => {


                this.setState({
                    screenurl: res.data.SchoolIdScreenUrl,
                    isWatch: res.data.isWatch,
                });
            })

            .catch((e) => {
                if (e.response) {
                    //请求已发出，服务器返回状态码不是2xx。
                    console.info(e.response.data)
                    console.info(e.response.status)
                    console.info(e.response.headers)
                } else if (e.request) {
                    // 请求已发出，但没有收到响应
                    // e.request 在浏览器里是一个XMLHttpRequest实例，
                    // 在node中是一个http.ClientRequest实例
                    console.info(e.request)
                } else {
                    //发送请求时异常，捕捉到错误
                    console.info('error', e.message)
                }
                console.info(e.config)
            });


        getUserPermissionApi(userId)
            .then(res => {
                console.log("Permission", res.data)
                this.setState({
                    loading: true,
                    menuData: res.data,
                    // menuData : ["修改密码"]
                });
            })
            .catch((e) => {
                if (e.response) {
                    //请求已发出，服务器返回状态码不是2xx。
                    console.info(e.response.data)
                    console.info(e.response.status)
                    console.info(e.response.headers)
                } else if (e.request) {
                    // 请求已发出，但没有收到响应
                    // e.request 在浏览器里是一个XMLHttpRequest实例，
                    // 在node中是一个http.ClientRequest实例
                    console.info(e.request)
                } else {
                    //发送请求时异常，捕捉到错误
                    console.info('error', e.message)
                }
                console.info(e.config)
            });
    }

    onCollapse = (collapsed) => {
        //console.log(collapsed);
        if (collapsed) {
            document.getElementById("logoName").style.display = "none";
        } else {
            document.getElementById("logoName").style.display = "inline";
        }
        this.setState({ collapsed });
    }
    updateHandleClick = () => {
        this.setState({
            updatePwdVisible: true,
        })
    }
    handleCancel = () => {
        let val = this.refs.updatePwdFormValue;
        val.resetFields();
        this.setState({
            updatePwdVisible: false,
            alertVisible: false,
            msg: ""
        })
    }

    handleClose = () => {
        this.setState({
            alertVisible: false,
            msg: ""
        })
    }
    updatePwdClick = (username) => {
        this.setState({
            confirmLoading: true,
            msg: "",
            alertVisible: false
        });
        let val = this.refs.updatePwdFormValue;
        val.validateFields((err, values) => {
            console.log(values.password)
            if (values.password != values.repassword) {
                this.setState({
                    alertVisible: true,
                    confirmLoading: false,
                    msg: "两次输入密码不一致,请重新输入!"
                });
            } else if (values.password == "" || values.repassword == "" || values.password == undefined
                || values.repassword == undefined) {
                this.setState({
                    alertVisible: true,
                    confirmLoading: false,
                    msg: "密码不可为空,请重新输入!"
                });
            } else if (values.password.length < 6) {
                this.setState({
                    alertVisible: true,
                    confirmLoading: false,
                    msg: "密码长度为6-16字符,请重新输入"
                });
            } else {
                var flag = this.judgePassword(values.password)
                values.department = sessionStorage.getItem("departmentId");
                if (flag == 1) {
                    this.setState({
                        alertVisible: true,
                        confirmLoading: false,
                        msg: "密码过于简单，6-16字符且由数字、字母和特殊字符中的2种组合"
                    });
                } else if (flag == 2) {
                    this.setState({
                        alertVisible: true,
                        confirmLoading: false,
                        msg: "密码不符合规范，请重新输入"
                    });
                } else {
                    updateUserApi(username, values)
                        .then((res) => {
                            if (res.data == "success") {
                                this.setState({
                                    updatePwdVisible: false,
                                    confirmLoading: false
                                });
                                message.success("修改成功!");
                                val.resetFields();
                                sessionStorage.setItem("password", values.password)
                            } else if (res.data == "fail") {
                                this.setState({
                                    alertVisible: true,
                                    updatePwdVisible: true,
                                    confirmLoading: false,
                                    msg: "修改失败,请检查信息或稍后再试!"
                                });
                            }
                        })
                }
            }


        });
    }


    getData = (data) => {
        console.log("子组件传过来的flag", data)
        this.setState({
            flag: [...data]
        })
        this.props.history.push("/")

    }

    // loginBigScreen = () => {
    //     console.log("跳转大屏伪登录====================")
    //     let username =  sessionStorage.getItem("username");
    //     let password =  sessionStorage.getItem("password");

    //     loginBigScreenApi(username, password).then((res) => {
    //         console.log("res.data=================", res.data)
    //     })

    // }


    redirect = () => {
        this.setState({
            buttonLoading: true
        })
       let name = sessionStorage.getItem("departmentName")
       
        let key = "123456******789"
        getScreenSecretApi(name, key).then((res) => {
            this.setState({
                buttonLoading: false
            })
            
            //const w = window.open('http://localhost:3000/edubigscreen/' + res.data);
            const w = window.open('http://47.111.158.147:3000/edubigscreen/' + res.data);
            // const w = window.open('https://tidukeji.cn/edubigscreen/' + res.data);
            // const w = window.open('https://tidukeji.cn/bigScreen/#/city/' + parseInt(sessionStorage.getItem("departmentId")) + "/" + res.data)
            // const w = window.open('http://localhost:3001/bigScreen/#/city/' + parseInt(sessionStorage.getItem("departmentId")) + "/" + res.data)
        })
    }
    redirect2 = () => {
        this.setState({
            buttonLoading: true
        })
        let name = sessionStorage.getItem("departmentName")
        let key = "987654******321"
        getScreenSecretApi(name, key).then((res) => {
            this.setState({
                buttonLoading: false
            })

            //const w = window.open('http://localhost:3000/edubigscreen/county/' + parseInt(sessionStorage.getItem("departmentId")) + '/' + res.data);
            const w = window.open('http://47.111.158.147:3000/edubigscreen/county/' + parseInt(sessionStorage.getItem("departmentId")) + '/' + res.data);
           // const w = window.open('http://tidukeji.cn/edubigscreen/county/' + parseInt(sessionStorage.getItem("departmentId")) + '/' + res.data);
        // const w = window.open('https://tidukeji.cn/bigScreen/#/county/' + parseInt(sessionStorage.getItem("departmentId")) + "/" + res.data)
        // const w = window.open('http://localhost:3001/bigScreen/#/county/' + parseInt(sessionStorage.getItem("departmentId")) + "/" + res.data)
            
        })
    }
    

    render() {
        // var departmentName = encodeURI(encodeURI(sessionStorage.getItem('departmentName')))
        var departmentName = sessionStorage.getItem('departmentName')
        var sub = '/edubigscreen/' + parseInt(sessionStorage.getItem('departmentId')) + "/" + departmentName + '/';
        //maptype 0 全市地图 1 区级地图

        // let moduleString =  encodeURI(encodeURI(sessionStorage.getItem('arr') ))|| "巡更,巡检"
        let moduleString = sessionStorage.getItem('arr') || "巡更,巡检"

        // var path = parseInt(sessionStorage.getItem('departmentId')) == 1 || parseInt(sessionStorage.getItem('departmentId')) == 0 ? sub + 0 + '' : sub + 1 + ''

        // var path1 = '/edubigscreen' + (parseInt(sessionStorage.getItem('departmentId')) == 1 ? "" : "/county/" + parseInt(sessionStorage.getItem('departmentId')));



        //origin： app  后台安全网格大屏链接进入   edu  教育局大屏子地图进入
        let origin = 'app'
        // var screenath = '/bigscreen/polling/' + parseInt(sessionStorage.getItem('departmentId')) + "/" + departmentName + '/' + 1 + '/' + moduleString + '/' + origin
        var screenath = '/bigscreen/patrol/' + parseInt(sessionStorage.getItem('departmentId'))  + '/' + 1;

        if (this.state.loading === true) {
            let routes = [];
            const menu = this.state.menuData.map(val => {
                const subMenu = val.childFeatures.map(subVal => {
                    routes.push(val.route + subVal.route)
                    return (
                        <Menu.Item key={subVal.key}>
                            <Link to={val.route + subVal.route}>
                                <IconFont type={subVal.icon} className='icon' />
                                <span className="nav-text">{subVal.name}</span>
                            </Link>
                        </Menu.Item>
                    )
                });
                return (
                    (
                        <SubMenu
                            key={val.key}
                            title={
                                <span>
                                    <IconFont type={val.icon} className='icon' />
                                    <span>{val.name}</span>
                                </span>
                            }>
                            {subMenu}
                        </SubMenu>
                    )
                );
            });


            return (
                <Router>

                    <Layout>
                        <Sider
                            collapsible
                            collapsed={this.state.collapsed}
                            onCollapse={this.onCollapse}
                            width={256}
                            style={{
                                height: "100vh",
                                left: 0,
                                overflow: 'hidden',
                            }}>
                            <div className="logo" >
                                {/* <IconFont type="icon-anfang" className='icon' style={{ verticalAlign: "middle", }} /> */}
                                <img
                                    src={require('../img/newLogo.png')}
                                    className='icon'
                                    style={{
                                        verticalAlign: 'middle',
                                        width: '30px',
                                        marginRight: 10
                                    }} />
                                <div
                                    id='logoName'
                                    style={{ verticalAlign: 'middle', display: 'inline-block', paddingLeft: "5px" }}>
                                    梯度安全网格
                                </div>
                            </div>
                            <Menu
                                className='innerbox'
                                theme="dark"
                                mode="inline"
                                defaultOpenKeys={this.state.defaultOpenKeys}
                                defaultSelectedKeys={this.state.defaultSelectedKeys}>
                                {menu}
                            </Menu>
                        </Sider>
                        <Layout style={{ height: "100vh" }}>
                            <Header style={{
                                background: '#fcfcfc',
                                padding: 0,
                                fontFamily: 'Microsoft Yahei, sans-serif',
                                fontSize: 15,
                                position: 'relative',
                                height: '64px',
                                lineHeight: '64px',
                            }}>
                                <div style={{ position: "absolute", top: 0, bottom: 0, left:'47.5%', transform:'translate(-47.5%,0)' }}>
                                    <IconFont
                                        type="icon-school"
                                        style={{ fontSize: '32.5px', color: '#1890FF' }} />
                                    <span style={{ marginLeft: '10px', fontSize: '25px' }}>{sessionStorage.getItem("departmentName")}</span>
                                </div>
                                {/* <a href={path1} target="_blank"><div style={{ position: "absolute", top: 0, bottom: 0, right: 590, display: 'block' }}

                                        >

                                            <IconFont
                                                type="icon-pingmu"
                                                style={{ fontSize: '28px', color: '#1890FF', verticalAlign: 'middle' }} />
                                            <Button>
                                                <span style={{ marginLeft: '5px', marginRight: '2px', color: '#60A4E3' }}>安全网格大屏</span></Button>
                                        </div></a> */}
                                {

                                    sessionStorage.getItem("departmentType") == "学校" ?
                                        (
                                            parseInt(sessionStorage.getItem("departmentId")) != 4 ?


                                                (<a href={screenath} target="_blank" onClick={info}><div style={{ position: "absolute", top: 0, bottom: 0, right: 190, display: 'block' }}

                                                >
                                                    <IconFont
                                                        type="icon-pingmu"
                                                        style={{ fontSize: '28px', color: '#1890FF', verticalAlign: 'middle' }} />
                                                    <span style={{ marginLeft: '5px', marginRight: '2px', color: '#60A4E3' }}>安全网格大屏</span>
                                                </div></a>) : (<div className='dropdown' style={{ position: "absolute", top: 0, bottom: 0, right: 190, display: this.state.isWatch ? 'block' : 'none' }} >
                                                    <a onClick={info} href={this.state.screenurl} target={this.state.isWatch ? '_blank' : ''}>   <IconFont
                                                        type="icon-pingmu"
                                                        style={{ fontSize: '28px', color: '#1890FF', marginRight: "2px", marginBottom: "-2px", verticalAlign: 'middle' }} />安全网格大屏</a>
                                                </div>)





                                        ) :
                                        (
                                            <div style={{ position: "absolute", top: 0, bottom: 0, right: 190, display: 'block' }}>
                                                <IconFont
                                                    type="icon-pingmu"
                                                    style={{ fontSize: '28px', color: '#1890FF', verticalAlign: 'middle' }} />
                                                {
                                                    (sessionStorage.getItem("departmentType") == "教育局" || parseInt(sessionStorage.getItem("departmentId")) == 0)?
                                                    (
                                                    <Button onClick={this.redirect} loading={this.state.buttonLoading}>
                                                        <span style={{ marginLeft: '5px', marginRight: '2px', color: '#60A4E3' }}>安全网格大屏</span>
                                                    </Button>
                                                    ):
                                                    (
                                                    <Button onClick={this.redirect2} loading={this.state.buttonLoading}>
                                                        <span style={{ marginLeft: '5px', marginRight: '2px', color: '#60A4E3' }}>安全网格大屏</span>
                                                    </Button>
                                                    )
                                                }
                                            </div>
                                        )

                                }



                                <div style={{ position: "absolute", top: 0, bottom: 0, right: 24, }}>
                                    <Dropdown overlay={
                                        <Menu>
                                            <Menu.Item>
                                                <a
                                                    class='logOff'
                                                    style={{ color: '#333333', padding: '5px 15px' }}
                                                    onClick={this.updateHandleClick.bind(this)}>
                                                    <IconFont
                                                        type="icon-xiugaimima" className='icon'
                                                        style={{ fontSize: '14px', verticalAlign: 'middle' }} />
                                                    <span style={{ verticalAlign: 'middle', marginLeft: '2px' }}>修改密码</span>
                                                </a>,
                                                <a
                                                    class='logOff'
                                                    style={{ color: '#333333', padding: '5px 15px' }}
                                                    onClick={() => this.logOff()}>
                                                    <IconFont
                                                        type="icon-zhuxiaologout11" className='icon'
                                                        style={{ fontSize: '14px', verticalAlign: 'middle' }} />
                                                    <span style={{ verticalAlign: 'middle', marginLeft: '2px' }}>退出登录</span>
                                                </a>
                                            </Menu.Item>
                                        </Menu>
                                    }>
                                        <div
                                            className='dropdown'
                                            style={{
                                                padding: '0px 5px'
                                            }}>
                                            <IconFont
                                                style={{ fontSize: '28px', verticalAlign: 'middle' }}
                                                type="icon-touxiang-shi" className='icon' />
                                            <span style={{ marginLeft: '2px' }}>{sessionStorage.getItem("username")}</span>
                                        </div>
                                    </Dropdown>
                                    <Modal
                                        title="修改密码"
                                        visible={this.state.updatePwdVisible}
                                        onCancel={this.handleCancel.bind(this)}
                                        closable
                                        footer={[
                                            <Button key="submit" type="primary" size="large"
                                                loading={this.state.confirmLoading}
                                                onClick={this.updatePwdClick.bind(this, sessionStorage.getItem("username"))}>提交</Button>
                                        ]}
                                    >
                                        <UpdatePwdForm ref="updatePwdFormValue" />
                                        {
                                            this.state.alertVisible ?
                                                (
                                                    <Alert message={this.state.msg} type="error" closable afterClose={this.handleClose.bind(this)} />
                                                ) : null
                                        }
                                    </Modal>
                                </div>
                            </Header>
                            <Content style={{ margin: "24px", overflow: 'auto', padding: 24 }}>
                                <div
                                    id="right"
                                    style={{
                                        // padding: 24,
                                        background: "#fff",

                                        marginBottom: 0
                                    }}
                                >
                                    <Switch>

                                        {pages.map((item, index) => {
                                            return (routes.indexOf(item.path) > -1 ? <Route path={item.path} component={item.component} /> : null)
                                        })
                                        }

                                    </Switch>
                                    {/* {
                                        this.state.flag !=0 ? <UpdatePassword flag={this.state.flag} getData={this.getData}/> : null
                                    } */}

                                </div>
                                {/* <div style={{ width: "100%", textAlign: "center", marginTop: '20px', zIndex: '3' }}>

                                    <p style={{ textAlign: "center", height: 20, color: "#939393" }}>
                                        CopyRight{"   "}  梯度安全网格版权所有 {"  "}
                                        <a href="http://beian.miit.gov.cn/" target="_blank" style={{
                                            display: "inline-block",
                                            textDecoration: "none",
                                            color: "#808080"
                                        }}> 浙ICP备19000794-1号</a>
                                    </p>


                                    <p style={{ textAlign: "center", height: 20, color: "#939393" }}>
                                        <img src="../img/beiantubiao.png" style={{ display: "inline" }} />
                                        < a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33010802010966"
                                            style={{ display: 'inline', textDecoration: 'none', }}>浙公网安备 33010802010966号</a></p>


                                </div> */}
                            </Content>

                        </Layout>


                    </Layout>


                </Router>

            )
        }

        else return null
    }
}
const FormItem = Form.Item;
class updatePwdForm extends Component {
    constructor(props) {
        super(props);
        this.setState({
        })

    }

    componentWillReceiveProps(props) {
    }

    componentDidMount() {

    }

    render() {
        const { getFieldDecorator } = this.props.form;
        const formItemLayout = {
            labelCol: { span: 4 },
            wrapperCol: { span: 16 },
        };

        return (
            <Form>
                <div>
                    <FormItem
                        label='新密码'
                        {...formItemLayout}>
                        {getFieldDecorator("password", {
                            rules: [{
                                required: true,
                                message: '请输入新密码！',
                            }]
                        })(
                            <Input
                                size="large"
                                prefix={
                                    <Icon type="lock" style={{ color: "rgba(0,0,0,.25)" }} />
                                }
                                type="password"
                                placeholder="请输入新密码"
                                maxLength={16}
                                minLength={6}
                            />
                        )}
                    </FormItem>
                    <FormItem
                        label='重复密码'
                        {...formItemLayout}>
                        {getFieldDecorator("repassword", {
                            rules: [{
                                required: true,
                                message: '请重复输入新密码！',
                            }]
                        })(
                            <Input
                                size="large"
                                prefix={
                                    <Icon type="lock" style={{ color: "rgba(0,0,0,.25)" }} />
                                }
                                type="password"
                                placeholder="请重复密码"
                                maxLength={16}
                                minLength={6}
                            />
                        )}
                    </FormItem>
                    <div style={{ fontSize: 12, fontWeight: 500, marginLeft: '10px' }}>
                        *密码规则:长度为6-16个字符，数字、字母和特殊字符中的任意2种组合
                    </div>
                </div>
            </Form>
        );
    }
}
const UpdatePwdForm = Form.create()(updatePwdForm);


export default App;